class OmniauthCallbacksController < ApplicationController

  def google_oauth2
    user = User.from_omniauth(request.env["omniauth.auth"])
    if user.persisted?
      flash.notice = "Signed in Through Google!"
      sign_in_and_redirect user
    else
      sign_in_and_redirect user
      #session["devise.user_attributes"] = user.attributes
      #flash.notice = "You are almost Done! Please provide a password to finish setting up your account"
      #redirect_to current_profile_path #new_user_registration_url
    end
  end

  def mobile_auth
    user = User.from_mobile(params[:email], params[:token])
    unless user.nil?
      sign_in user
      user.ensure_authentication_token!
      render :json => { :response => 'ok', :token => user.authentication_token }.to_json, :status => :ok
    end
  end
end
